﻿using System.Data.Entity;
using System.Linq;
using System.Net;
using System.Web.Mvc;
using CatHouse.Controllers;
using CatHouse.Models;

namespace CatHouse.Areas.QuanLy.Controllers
{
    public class NhanVienController : BaseAdminController
    {
        // GET: /QuanLy/NhanVien/
        public ActionResult Index()
        {
            return View(Db.Abouts.ToList());
        }

        // GET: /QuanLy/NhanVien/Details/5
        public ActionResult Details(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            AboutModel aboutmodel = Db.Abouts.Find(id);
            if (aboutmodel == null)
            {
                return HttpNotFound();
            }
            return View(aboutmodel);
        }

        // GET: /QuanLy/NhanVien/Create
        public ActionResult Create()
        {
            return View();
        }

        // POST: /QuanLy/NhanVien/Create
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Create([Bind(Include="Ten,NgaySinh,AnhChanDung,Email,ThongTinCaNhan,Facebook")] AboutModel aboutmodel)
        {
            if (ModelState.IsValid)
            {
                Db.Abouts.Add(aboutmodel);
                Db.SaveChanges();
                return RedirectToAction("Index");
            }

            return View(aboutmodel);
        }

        // GET: /QuanLy/NhanVien/Edit/5
        public ActionResult Edit(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            AboutModel aboutmodel = Db.Abouts.Find(id);
            if (aboutmodel == null)
            {
                return HttpNotFound();
            }
            return View(aboutmodel);
        }

        // POST: /QuanLy/NhanVien/Edit/5
        // To protect from overposting attacks, please enable the specific properties you want to bind to, for 
        // more details see http://go.microsoft.com/fwlink/?LinkId=317598.
        [HttpPost]
        [ValidateAntiForgeryToken]
        public ActionResult Edit([Bind(Include="ID,Ten,NgaySinh,AnhChanDung,Email,ThongTinCaNhan,Facebook")] AboutModel aboutmodel)
        {
            if (ModelState.IsValid)
            {
                Db.Entry(aboutmodel).State = EntityState.Modified;
                Db.SaveChanges();
                return RedirectToAction("Index");
            }
            return View(aboutmodel);
        }

        // GET: /QuanLy/NhanVien/Delete/5
        public ActionResult Delete(int? id)
        {
            if (id == null)
            {
                return new HttpStatusCodeResult(HttpStatusCode.BadRequest);
            }
            AboutModel aboutmodel = Db.Abouts.Find(id);
            if (aboutmodel == null)
            {
                return HttpNotFound();
            }
            return View(aboutmodel);
        }

        // POST: /QuanLy/NhanVien/Delete/5
        [HttpPost, ActionName("Delete")]
        [ValidateAntiForgeryToken]
        public ActionResult DeleteConfirmed(int id)
        {
            AboutModel aboutmodel = Db.Abouts.Find(id);
            Db.Abouts.Remove(aboutmodel);
            Db.SaveChanges();
            return RedirectToAction("Index");
        }

        protected override void Dispose(bool disposing)
        {
            if (disposing)
            {
                Db.Dispose();
            }
            base.Dispose(disposing);
        }
    }
}
